/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lt.cj.core.filters;

import org.htmlparser.Node;
import org.htmlparser.NodeFilter;

/*
 * @author luohong
 * 正则匹配过滤
 */
public class RegFilterImpl implements NodeFilter {

    private String regularExpression;

    public RegFilterImpl(String regularExpression) {

        this.regularExpression = regularExpression;
    }

    public boolean accept(Node node) {

        if (node.getText().indexOf(regularExpression) != -1 && (node.getText().trim().startsWith(regularExpression) || node.getText().trim().endsWith(regularExpression))) {
            return true;
        }
        return false;
    }
}
